package cn.yunhe.dao;

import cn.yunhe.model.User;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.simple.ParameterizedRowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

public interface UserDao {

    User findById(int id);
    List<User>searchUser();
    List<User>searchUser(User user);

    boolean insertUser(User user);
    boolean updateUser(User user);
    boolean deleteUser(User user);

    public static final
    /*RowMapper rowMapper=new RowMapper() {*/
    RowMapper rowMapper=new ParameterizedRowMapper() {
        @Override
        public User mapRow(ResultSet resultSet, int i) throws SQLException {
            User user=new User();
            user.setId(resultSet.getInt("id"));
            user.setUname(resultSet.getString("uname"));
            user.setUpwd(resultSet.getString("upwd"));
            return user;
        }
    };
}
